﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq.Mapping;
using System.Data.Linq;
using System.Reflection;

namespace CoolCode.Data.Linq
{
    public partial class XDataContext
    {
        public string GetDocNo(string docType)
        {
            return GetDocNo(docType, DateTime.Now);
        }

        public string GetDocNo(string docType, DateTime docDate)
        {
            return GetDocNo(docType, docDate, string.Empty);
        }

        public string GetDocNo(string docType, DateTime docDate, string division)
        {
            string docNo = string.Empty;
            GetDocNoHelper(docType, docDate, division, ref docNo);
            return docNo;
        }
 
        [Function(Name = "dbo.usp_GetDocNo")]
        public int GetDocNoHelper(
            [Parameter(Name = "INDOCTYP", DbType = "NVarChar(3)")] string docType,
            [Parameter(Name = "INDOCDTE", DbType = "DateTime")]DateTime docDate,
            [Parameter(Name = "INDIVCD", DbType = "NVarChar(10)")] string division,
            [Parameter(Name = "OUTDOCNO", DbType = "NVarChar(15)")] ref string docNo)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), docType, docDate, division, docNo);
            docNo = ((string)(result.GetParameterValue(3)));
            return ((int)(result.ReturnValue)); 
        }

    }
}
